Interactive Data Viz Examples

Animated Gapminder Data

For a demonstration of plot that we animate to view evolution over time, see Figure 1.

Code
import plotly.express as px
gp = px.data.gapminder()
px.scatter(gp, x="gdpPercap", y="lifeExp", 
           animation_frame="year", animation_group="country",
           size="pop", color="continent", hover_name="country",
           log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90])
Figure 1: Animation of the Gapminder Dataset

Linked Viz for Gapminder Data

For a demonstration plots that allow for interactive views of feature variation, see Figure 2.

Code
import altair as alt
import math

continent_selection = alt.selection_point(
    fields=['continent'], 
    bind='legend'
)

points = alt.Chart(gp).mark_point().encode(
    alt.X('gdpPercapLog', scale=alt.Scale(domain=[4, 12])),
    alt.Y('lifeExp', scale=alt.Scale(domain=[20, 90])),
    color='continent'
).add_params(
    my_si,
    continent_selection
).transform_filter(
    continent_selection
)

barsX = alt.Chart(gp).mark_bar().encode(
    alt.X('gdpPercapLog', bin=True, scale=alt.Scale(domain=[4, 12])),
    y='count()',
    color='continent'
).transform_filter(
    my_si
).transform_filter(
    continent_selection
)

barsY = alt.Chart(gp).mark_bar().encode(
    alt.Y('lifeExp', bin=True, scale=alt.Scale(domain=[20, 90])),
    x='count()',
    color='continent'
).transform_filter(
    my_si
).transform_filter(
    continent_selection
)

chart = alt.vconcat(
    barsX,
    alt.hconcat(points, barsY)
)

chart.show()
Figure 2: Interactive Views of Gapminder Dataset Variation